﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Framework;
using Framework.Event;
using System.Runtime.InteropServices;
using System.IO;
using System.Text;
using UnityEngine.Profiling;


public class TestBehaviour : MonoBehaviour
{

    // Start is called before the first frame update
    void Start()
    {
        TestClass2 temp = new TestClass2();
        temp.DoTest();
        // EventDispatcher temp = new EventDispatcher();
        // temp.AddListener("test", this.TestEvent);
        // temp.AddListener<int>("test", this.TestEvent);
        // temp.BroadCast("test", 1);
        // temp.DelListener<int>("test", this.TestEvent);
        // temp.BroadCast("test", 1);
        // temp.AddListener<int>("test", this.TestEvent);
    }

    void TestStruct(TestStruct input)
    {
    }

    void TestClass(TestClass input)
    {
    }

    void TestEvent()
    {
        Log.Info("TestEvent--->");
    }

    void TestEvent(int a)
    {
        Log.Info("TestEvent---int>" + a);
    }

    void TestMemoryStream()
    {
        MemoryStream ms = new MemoryStream();
        Debug.Log("Start--->");
        Debug.Log(ms.CanRead);
        Debug.Log(ms.CanSeek);
        Debug.Log(ms.CanWrite);
        Debug.Log(ms.Capacity);
        Debug.Log(ms.Length);
        Debug.Log(ms.Position);
        byte[] bytes = Encoding.UTF8.GetBytes("1234567");
        ms.Write(bytes, 0, bytes.Length);
        Debug.Log("After--->");
        Debug.Log(ms.Capacity);
        Debug.Log(ms.Length);
        Debug.Log(ms.Position);
        Debug.Log(Encoding.UTF8.GetString(ms.ToArray()));

        Debug.Log("Test2--->");
        // ms.Seek(2, SeekOrigin.Current);
        byte[] bytes2 = Encoding.UTF8.GetBytes("abc");
        ms.Write(bytes2, 0, bytes2.Length);
        Debug.Log(ms.Capacity);
        Debug.Log(ms.Length);
        Debug.Log(ms.Position);
        Debug.Log(Encoding.UTF8.GetString(ms.ToArray()));
    }

    private void Update()
    {
        Profiler.BeginSample("TestSelfCode");
        // Debug.Log(1);
        Profiler.EndSample();
    }
}
